% This is a project to measure Cat's Visual Accuity
clear all
close all

cat_sit_height=500;  % measure JinBao
ceiling_height=2400; % measure the ceiling
projector_height=1800; % measure the projector
projector_ratio=0.78; % screen/projector_distance

visual_length=ceiling_height-cat_sit_height;
projector_distance=ceiling_height-projector_height;
ps_width=projector_distance*projector_ratio;
dd=ps_width/800; %dot distance

va=[0.8,0.6,0.4,0.2,0.1,0.08,0.05];
cycle=floor((tan(1/30/180*pi./va)*visual_length/(dd))./2)*2;
[x,maxi]=size(cycle);

w=100;
alpha=0;
for i=1:maxi
    t=cycle(i);
 e=meshgrid(0:2*w);
 e=mod(e,t)./t*2*pi;
 e=imrotate(e,alpha,'bilinear','crop');
 e=imcrop(e,[w/2 w/2 w-1 w-1]);
 e=uint8((1/2.*(cos(e)+1)).*255);
 figure(i),imshow(e)
 filename=['strip' num2str(i) '.jpg']
 imwrite(e, filename);
     
end

% imwrite(e,'bw.png');